Skip to content

Add c10::irange to ExecuTorch #8554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 19, 2025
Merged

Conversation

swolchok
Copy link
Contributor

@swolchok swolchok commented Feb 19, 2025

Stack from ghstack (oldest at bottom):

irange is a header-only utility that is both more readable than the usual way to write for loops and also solves -Wsign-compare issues. I've previously vetted that it generates the same assembly as a regular for loop.

Differential Revision: D69817195

irange is a header-only utility that is both more readable than the usual way to write for loops and also solves -Wsign-compare issues. I've previously vetted that it generates the same assembly as a regular for loop.

Differential Revision: [D69817195](https://our.internmc.facebook.com/intern/diff/D69817195/)

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Feb 19, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8554

Note: Links to docs will display an error until the docs builds have been completed.

❌ 3 New Failures, 2 Pending

As of commit 1cd3b5c with merge base cc3974f (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 19, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69817195

swolchok pushed a commit that referenced this pull request Feb 19, 2025
irange is a header-only utility that is both more readable than the usual way to write for loops and also solves -Wsign-compare issues. I've previously vetted that it generates the same assembly as a regular for loop.

Differential Revision: [D69817195](https://our.internmc.facebook.com/intern/diff/D69817195/)

ghstack-source-id: 267074908
Pull Request resolved: #8554
@@ -26,6 +26,7 @@ def define_common_targets():
"util/TypeSafeSignMath.h",
"util/bit_cast.h",
"util/floating_point_utils.h",
"util/irange.h",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is irange.h not part of headers from pytorch? or we decided that is not worth sharing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is a pytorch header, but it is used in executorch core. therefore it must be copied over just like everything else in runtime/core/portable_type/c10/c10 to keep the build hermetic for embedded users

@@ -0,0 +1,123 @@
// Copyright 2004-present Facebook. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the copy right in line with rest of the codebase?

@@ -0,0 +1,123 @@
// Copyright 2004-present Facebook. All Rights Reserved.

#pragma once
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this file is copied over, can you add a comment here to the effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment

no. the file should be identical to the version in pytorch core.


#include <c10/util/TypeSafeSignMath.h>

#include <algorithm>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it need <algorithm>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not relevant; this is a direct copy from pytorch core.

@@ -11,6 +11,8 @@
#include <algorithm>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not related to this diff per se, but makes me curious why we need in this file too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,123 @@
// Copyright 2004-present Facebook. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Add BSD license header

Also, i have a task to add a lint rule: #8418

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irange is a header-only utility that is both more readable than the usual way to write for loops and also solves -Wsign-compare issues. I've previously vetted that it generates the same assembly as a regular for loop.

Differential Revision: [D69817195](https://our.internmc.facebook.com/intern/diff/D69817195/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69817195

swolchok pushed a commit that referenced this pull request Feb 19, 2025
Pull Request resolved: #8554

irange is a header-only utility that is both more readable than the usual way to write for loops and also solves -Wsign-compare issues. I've previously vetted that it generates the same assembly as a regular for loop.
ghstack-source-id: 267193301
@exported-using-ghexport

Differential Revision: [D69817195](https://our.internmc.facebook.com/intern/diff/D69817195/)
irange is a header-only utility that is both more readable than the usual way to write for loops and also solves -Wsign-compare issues. I've previously vetted that it generates the same assembly as a regular for loop.

Differential Revision: [D69817195](https://our.internmc.facebook.com/intern/diff/D69817195/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69817195

swolchok pushed a commit that referenced this pull request Feb 19, 2025
Pull Request resolved: #8554

irange is a header-only utility that is both more readable than the usual way to write for loops and also solves -Wsign-compare issues. I've previously vetted that it generates the same assembly as a regular for loop.
ghstack-source-id: 267194238
@exported-using-ghexport

Differential Revision: [D69817195](https://our.internmc.facebook.com/intern/diff/D69817195/)
@swolchok swolchok added the release notes: api Changes to public facing apis (any interfaces, pybinded runtime methods, etc.) label Feb 19, 2025
@swolchok
Copy link
Contributor Author

checked lint; it's an unrelated cadence issue. merging

@swolchok swolchok merged commit 7b484d9 into gh/swolchok/270/base Feb 19, 2025
45 of 49 checks passed
@swolchok swolchok deleted the gh/swolchok/270/head branch February 19, 2025 17:38
swolchok pushed a commit that referenced this pull request Feb 19, 2025
Pull Request resolved: #8554

irange is a header-only utility that is both more readable than the usual way to write for loops and also solves -Wsign-compare issues. I've previously vetted that it generates the same assembly as a regular for loop.
ghstack-source-id: 267194238
@exported-using-ghexport

Differential Revision: [D69817195](https://our.internmc.facebook.com/intern/diff/D69817195/)

Co-authored-by: Github Executorch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported release notes: api Changes to public facing apis (any interfaces, pybinded runtime methods, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants